package softserve.vgolosh;

import java.io.File;
import java.util.List;
import java.util.Scanner;

import softserve.vgolosh.utils.CmdUtil;
import softserve.vgolosh.utils.FileUtil;
import softserve.vgolosh.utils.PropertiesHelper;
import softserve.vgolosh.utils.PropertyNotFoundException;

public class MainClass {
	private static String BEYOND_COMPARE = "C:\\Program Files\\Beyond Compare 3";
	public static String TRUNK_WORKING_DIR = "d:\\svnwork\\customers\\trunk\\working\\";
	public static String BRANCH_CLEAN_DIR = "d:\\svnwork\\customers\\branch\\clean\\";
	static {
		if (PropertiesHelper.isInitialised()) {
			try {
				BEYOND_COMPARE = PropertiesHelper.getProperty("BEYOND_COMPARE");
			} catch (PropertyNotFoundException e) {
				System.out.println(e);
				System.out.println("using default value " + BEYOND_COMPARE);
			}
		}
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String trunk_working = PropertiesHelper.TRUNK_WORKING_DIR;
		String branch_clean = PropertiesHelper.WORKING_DIR
				+ "\\branch\\clean\\";
		List<String> fileNames = FileUtil.getClientDirectories(trunk_working);
		File dir = null;
		for (String file : fileNames) {
			String[] commands = new String[] {
					"cmd.exe",
					"/c",
					"BCompare.exe " + branch_clean + file + " " + trunk_working
							+ file };
			dir = new File(BEYOND_COMPARE);
			CmdUtil.startCommand(commands, dir);
		}
		scanner.nextLine();
	}
}
